/******************************************************************************
 * Copyright (C) 2017 Chengdu Dlhd information industry co. LTD.
 * All Rights Reserved.
 * 本软件为成都顶联互动信息产业有限公司开发研制。未经本公司正式书面同意，其他任何个人、团体不得使用、复制、修改或发布本软件.
 *****************************************************************************/
package net.dgg.dggcloud.service.jrcrm.service.business;

import net.dgg.dggcloud.service.common.base.service.BaseService;
import net.dgg.dggcloud.service.jrcrm.dao.business.BusinessAllotCountDao;
import net.dgg.dggcloud.service.jrcrm.dao.business.BusinessAllotDeptCountDao;
import net.dgg.dggcloud.service.jrcrm.entity.business.BusinessAllotCount;
import net.dgg.dggcloud.service.jrcrm.entity.business.BusinessAllotDeptCount;
import net.dgg.dggcloud.service.service.organization.OrganizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @ClassName 〈BusinessAllotDeptCountService>
 * @Description 部门分配记录
 * @Author 罗金
 * @Date 2017/11/10 16:16
 */
@Service
public class BusinessAllotDeptCountService extends BaseService {
    @Autowired
    private OrganizationService organizationService;
    @Resource
    private BusinessAllotDeptCountDao businessAllotDeptCountDao;

    public List<Map> searchDeptAllotRecord(Long organizationId, String month) {
        Map cmap = new HashMap();
        cmap.put("allotMonth", month);
        cmap.put("organizationId", organizationId);
        return businessAllotDeptCountDao.listBusinessAllotDeptCountByMap(cmap);
    }

    /**
     * 获取部门的分配记录
     *
     * @param orgId       用户所在部门id
     * @param addTypeCode 分配类型
     * @param month       分配月份
     * @return
     */
    public BusinessAllotDeptCount getUserAllotCount(Long orgId, String addTypeCode, Integer month) {
        Map cmap = new HashMap();
        cmap.put("allotMonth", month);
        cmap.put("orgId", orgId);
     cmap.put("addTypeCode", addTypeCode);
     return businessAllotDeptCountDao.selectBusinessAllotDeptCountByMap(cmap);

     }

     /**
     * 查询部门中接单量小于某个数的部门列表
     *
     * @param month  月份
     * @param orgIds 部门id集合
     * @param number 小于几
     * @return
     */
    public List<Map> queryLessThanNumberUser(String month, String orgIds, Integer number) {
        Map cmap = new HashMap();
        cmap.put("allotMonth", month);
        cmap.put("orgIds", orgIds);
        cmap.put("number", number);
        return businessAllotDeptCountDao.queryLessThanNumberUserByMap(cmap);
    }

    public List<Map> listDeptBusinessAllotCountByMap(Map map){
        return businessAllotDeptCountDao.listDeptBusinessAllotCountByMap(map);
    }


}
